home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
SDIR24C.ASM
< prev
next >
Wrap
Assembly Source File
|
1984-02-07
|
47KB
|
930 lines
TITLE SDIR - SORTED DIRECTORY COMMAND, Version 2.4
PAGE 64,132 ; JAN 1983
COMMENT |
SDIR [d:][path][filename[.ext]] [options] 2.4
[filespec] same as for DIR command
[options] * /A - List hidden files.
* /E - Without screen erase.
* /P - Pause when screen full.
/X - Sort by extension.
/S - Sort by size.
/D - Sort by date/time.
/N - Do not sort, original order.
Default = *.* sorted by name.ext with screen erase.
* - Option may be combined with other options.
This source file was created from an object file obtained
from Gene Plantz's BBS in Chicago. The original file name
was SD.HEX. I then used DEBUG and CAPTURE to get the first
dis-assembly which was then edited with WORDSTAR to create
a source that when assembled using MASM would duplicate the
original object file.
Comments have been added and I do hope they are helpful.
I have made several modifications to the first version and
am continuing to add comments. This source file is an
excellent example for anyone wishing to learn 8086/8088
assembly language. Use at your own risk and feel free to
share this file with your friends.
I certainly wish that John Chapman would publish his
source file. His comments are sure to be more meaningful
than mine could ever be. Some of the conversion routines
are very elegant, but difficult to understand. As far as
I'm concerned, PRINTDD is magic.
Several modifications have been made. They are:
1. Filespecs are processed like DIR does.
2. No sort option was added. /N
3. Pause when screen full option added. /P
4. Number of files found is printed.
Ted Reuss
Houston, TX
SDIR Version 2.2 The GETFREE Subroutine was updated for DOS 2.0
April 1, 1983 by Jack Y. Fong
Changes are denoted by "JYF" at the end of changed lines.
SDIR Version 2.3:
Added display of current directory name and volume name
in header lines for DOS Release 2.0.
Added total of file sizes for the displayed files.
This is helpful in DOS 2.0 since it allows you to determine
the number of bytes used by all the files in a root or
subdirectory (or used by a specified subset of
the files in a root or subdirectory).
John F. Ratti 29 June, 1983
Changes are denoted by "2.3" at the end of the changed lines.
SDIR Version 2.4:
Added display of attribute byte. The column 'ATR' will display
up to 4 attribute codes. The codes are as follows:
A - Archive bit is off (file has been archived)
H - Hidden bit is on (file is hidden)
R - Read-only bit is on (file is read-only)
S - System bit is on (file is a system file)
Corrected display of hidden, system, read-only and directory
entries when /a option is specified.
Added pathname capability. Any pathname that DIR will accept
will work. The code should have been rewritten, rather than
modified. The resulting code is somewhat obtuse, and I
apologize for it. I plan to write a proper pathname
parser. When I do, I'll incorporate it into SDIR.
This version MUST be used under MS-DOS release 2.0.
John F. Ratti 03 July, 1983
Changes are denoted by "2.4" at the end of the changed lines.
|
SUBTTL EQUATES & STRUCTURES
PAGE
IF1
DOSCALL MACRO FUNC,PARM1
.xcref
F_C = FUNC
IFNB <PARM1>
IF F_C EQ 2 OR (F_C GE 4 AND F_C LE 6) OR F_C EQ 14 OR F_C EQ 46
MOV DL,PARM1
ELSE
MOV DX,OFFSET PARM1
ENDIF
ENDIF
MOV AH,FUNC
INT 21H
.cref
ENDM
ENDIF
.SALL ;supress all macro expansions
; PC-DOS INTERRUPT 21H FUNCTION CODES
;
@CHROUT EQU 2 ;display char in DL
@KEYIN EQU 8 ;kybd input w/o echo
@STROUT EQU 9 ;print string terminated with $
@CKEYIN EQU 12 ;clr kybd bufr & do inp.func in AL
@OPEN EQU 15 ;open XFCB 2.4
@SRCH1 EQU 17 ;search for first dir entry
@SRCH2 EQU 18 ;search for next dir entry
@GETDSK EQU 25 ;get default disk drive
@SETDTA EQU 26 ;set disk transfer addr
@FATAD2 EQU 28 ;get FAT of drive # in DL
@PARSEF EQU 41 ;parse filename
@GETDTE EQU 42 ;get system date
@GETTME EQU 44 ;get system time
@GETVER EQU 30H ;get version number JYF
@CTLBRK EQU 33H ;get/set ctrl/break checking 2.4
@DSKFSP EQU 36H ;get disk free space JYF
@CHDIR EQU 3BH ;change directory 2.4
@CHMOD EQU 43H ;change/get file mode 2.4
@GETCD EQU 47H ;get current directory 2.3
@FIND1 EQU 4EH ;find first dir. entry (DOS 2.0) 2.4
@FIND2 EQU 4FH ;find next dir entry (DOS 2.0) 2.4
CR EQU 0DH ;carriage return
LF EQU 0AH ;line feed
FCB_1 EQU 5CH ;fcb for parameter 1
PARAM_L EQU 80H ;# characters in PARAM_B
PARAM_B EQU 81H ;DOS cmd parameter buffer.
; PC-DOS packed date <yyyyyyym mmmddddd>
P_DTE RECORD P_YR:7,P_MO:4,P_DY:5
; PC-DOS packed time <hhhhhmmm mmmsssss>
P_TME RECORD P_HR:5,P_MI:6,P_2S:5
DIR RECORD P_YR:7,P_MO:4,P_DY:5
; PC-DOS packed time <hhhhhmmm mmmsssss>
P_TME RECORD P_HR:5,P_MI:6,P_2S:5
DIRNTRY STRUC ;directory entry structure
LNK DW 0 ;ptr to next entry
NAM DB 8 DUP(0),'.' ;filename
EXT DB 3 DUP(0) ;extension
TME DW 0 ;time
DTE DW 0 ;date
SZL DW 0 ;low word of size
SZH DW 0 ;high word of size
ATR DB 0 ;attribute byte 2.4
DIRNTRY ENDS
SUBTTL DATA AREA & INITIALIZATION
PAGE
SDIR SEGMENT PUBLIC 'CODE'
ASSUME CS:SDIR,DS:SDIR,ES:SDIR
ORG 100H
MAIN PROC FAR
JMP STARTS
DIRLNK DW DIRBUF ;ptr to next opening in DIRBUF
C1LNK DW 0 ;ptr to row 1, column 1
C2LNK DW 0 ;ptr to row 1, column 2
NBRFILS DW 0 ;# of files or detail lines
SRTFLG DB 0 ;if = 0 then sort else no sort
CLSFLG DB 0 ;if = 0 then clear screen
EXTFLG DB 0 ;if <> 0 then sort by ext
SIZFLG DB 0 ;if <> 0 then sort by size
DTEFLG DB 0 ;if <> 0 then sort by date/time
PSEFLG DB 0 ;if <> 0 then pause if screen full
LPERSCR EQU 25 ;Lines per screen
LINCNT DB LPERSCR-5 ;Number of lines left
PSEMSG DB 'Strike a key when ready . . . $'
HDNG1 DB 'SDIR: Sorted DIRectory listing, Version 2.4 '; 2.3
DB 'Volume ' ; 2.3
VOLNAME DB ' ' ; 2.3
D_MM DW '00' ;Month
DB '/'
D_DD DW '00' ;Day
DB '/'
D_YY DW '00' ;Year
DB ' '
T_HH DW '00' ;Hours
DB ':'
T_MM DW '00' ;Minutes
DB CR,LF,'$' ; 2.3
HDNG2 DB 32 DUP(' ') ; 2.3
DB 'Directory of ' ; 2.3
HDRVE DB '@:' ; 2.3
DIRNAME DB '\',69 DUP(0) ; directory name